package com.shen.jcbf.thread.volatilesy;

import java.util.HashSet;

public class TestVolatile {

	private volatile static boolean ready;
	private volatile static int number;

	private static class ReaderThread extends Thread {
		@Override
		public void run() {
			System.out.println(ready);
			while (!ready) {
				Thread.yield();
			}
			System.out.println(number);
		}
	}

	public static void main(String[] args) throws InterruptedException {
		new ReaderThread().start();
		Thread.sleep(1000);
		// ready = true;
		// Thread.sleep(1000);
		// number = 42;
		number = 42;
		Thread.sleep(1000);
		ready = true;
	}

}
